BIT_POPULATION

The BIT_POPULATION function returns the number of set (non-zero) bits in its integer argument.

Example

The following statement displays the number of bits in an IDL long integer:

PRINT, BIT_POPULATION('ffffffff'xl)

IDL prints:

32

Syntax

Result = BIT_POPULATION( Value )

Return Value

BIT_POPULATION returns the number of set (non-zero) bits in Value. If Value is an array, the result is an array with the same structure, where each element contains the count of non-zero bits in the corresponding element of Value.

Arguments

Value

A scalar or array of any integer type.

Keywords

Thread Pool Keywords

This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.

Version History

6.2

Introduced

See Also

Bitwise Operators, ISHFT, IDL_Variable::FromBits, IDL_Variable::ToBits